package com.codelife.shejimoshi.dailimoshi.dongtaidaili.JDK;



import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

/**
 * @ClassName Daili
 * @Description TODO
 * @Date 2019/11/5 10:21
 * @Version 1.0
 **/
public class Daili implements InvocationHandler {

    private Object target;

    public Object bind(Object object){
        this.target=object;
        return Proxy.newProxyInstance(object.getClass().getClassLoader(),object.getClass().getInterfaces(),this);
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

        Object result=null;

        System.out.println("预处理操作——————");
        //调用真正的业务方法
        result=method.invoke(target, args);

        System.out.println("调用后处理——————");
        return result;
    }
}
